package com.briup.ptt.config;

import com.briup.ptt.web.interceptor.JWTInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 杰瑞
 * @date 2025/8/15
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private JWTInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor)
                //拦截路径
                .addPathPatterns("/**")
                //排除不拦截路径
                .excludePathPatterns("/login",
                                    "/loginByEmail",
                                    "/sendEmail")
                .excludePathPatterns("/doc.html",
                                    "/swagger-resources/**",
                                    "/webjars/**");

    }
}
